import { lazy } from 'react'

// 导入要加渲染的页面
const Dashboard = lazy(() => import('../pages/admin/Dashboard'))
const UserAdmin = lazy(() => import('../pages/admin/UserAdmin'))
const BookManages = lazy(() => import('../pages/admin/BookManages'))
const BookTypekManages = lazy(() => import('../pages/admin/BookTypeManager'))
const RulesManager = lazy(() => import('../pages/admin/RulesManager'))
const OrdersManager = lazy(() => import('../pages/admin/OrderManager'))

const Error404 = lazy(() => import('../components/error/Error404'))

export type routerType = {
  key: string
  to: string
  content: any
}

const RouterConfig: routerType[] = [
  {
    key: '/dashboard',
    to: '/dashboard',
    content: Dashboard,
  },
  {
    key: '/admin/users',
    to: '/admin/users',
    content: UserAdmin,
  },
  {
    key: '/admin/auths',
    to: '/admin/auths',
    content: RulesManager,
  },
  {
    key: '/admin/books',
    to: '/admin/books',
    content: BookManages,
  },
  {
    key: '/admin/orders',
    to: '/admin/orders',
    content: OrdersManager,
  },
  {
    key: '/admin/books-type',
    to: '/admin/books-type',
    content: BookTypekManages,
  },
  {
    key: 'other',
    to: '*',
    content: Error404,
  },
]

export default RouterConfig
